﻿using System;
using System.Configuration;

namespace UFIDA.U9.WSS.ProxyService.AccessProxy.Configuration
{
    [ConfigurationCollection(typeof (ProxySection), AddItemName = "Proxy")]
    public class ProxySectionCollection : ConfigurationElementCollection
    {
        public ProxySectionCollection()
        {
            AddElementName = "Proxy";
        }

        protected override string ElementName
        {
            get { return "Proxy"; }
        }

        public ProxySection this[int index]
        {
            get { return (ProxySection) BaseGet(index); }
        }

        public new ProxySection this[string key]
        {
            get { return (ProxySection) BaseGet(key); }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new ProxySection();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException();
            }
            return ((ProxySection) element).ProxyType;
        }

        public void Add(ProxySection e)
        {
            BaseAdd(e);
        }

        public void Remove(ProxySection e)
        {
            if (e != null)
            {
                BaseRemove(e.ProxyType);
            }
        }

        public void Remove(string key)
        {
            BaseRemove(key);
        }

        public void Clear()
        {
            BaseClear();
        }
    }
}